package com.zyq.model.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.zyq.model.valid.group.UserEditValidGroup;
import com.zyq.model.valid.group.UserLoginValidGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.experimental.Accessors;
import net.bytebuddy.implementation.bind.annotation.Default;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * User
 * @author dolyw.com
 * @date 2018/8/31 14:43
 */
@Data
@Accessors(chain = true)
@Table(name = "user")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class User implements Serializable {

    private static final long serialVersionUID = 3342723124953988435L;

    /**
     * ID
     */
    @ApiModelProperty("id")
    @Id
    @GeneratedValue(generator = "JDBC")
    private Long id;

    /**
     * 帐号
     */
    @ApiModelProperty("帐号")
    @NotNull(message = "帐号不能为空", groups = { UserLoginValidGroup.class, UserEditValidGroup.class })
    private String account;

    /**
     * 密码
     */
    @ApiModelProperty("密码")
//    @NotNull(message = "密码不能为空", groups = { UserLoginValidGroup.class, UserEditValidGroup.class })
    private String password;

    /**
     * 昵称
     */
    @ApiModelProperty("昵称")
    @NotNull(message = "用户名不能为空", groups = { UserEditValidGroup.class })
    private String username;

    /**
     * 注册时间
     */
    @Column(name = "reg_time")
    @ApiModelProperty("注册时间")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date regTime;

    @ApiModelProperty("性别")
    private String sex;

    @ApiModelProperty("电话号码")
    @Column(name = "telephone_number")
    private String telephoneNumber;

    @ApiModelProperty("邮箱")
    @NotNull(message = "邮箱不能为空")
    private String email;

    @ApiModelProperty("用户凭证")
    private String proof;

    @ApiModelProperty("出生年月")
    private String birth;

    @ApiModelProperty("审核状态")
    private Long status;

    @ApiModelProperty("个人介绍")
    private String introduction;

    @Column(name = "role")
    @ApiModelProperty("用户角色")
    private String role;

//    @Builder.Default
    @ApiModelProperty("用户头像")
//    private String avatar="http://localhost:8888/static/people.png";
    private String avatar;

    @ApiModelProperty("粉丝数量")
    private String countFans;

    @ApiModelProperty("关注人数量")
    private String countAttention;
}
